<template>
  <ElSelect>
    <ElOption :value="SELECT_ALL_VALUE" label="全部"></ElOption>
    <!-- 此处未递归 只处理二级 -->
    <template v-for="item of list" :key="item.path">
      <ElOptionGroup v-if="item.children.length" :label="item.title">
        <ElOption
          v-for="child of item.children"
          :key="child.path"
          :label="child.title"
          :value="child.path"
        ></ElOption>
      </ElOptionGroup>
      <ElOption v-else :label="item.title" :value="item.path"> </ElOption>
    </template>
  </ElSelect>
</template>
<script lang="ts" setup>
import { routes } from "@/router";
import { generateRouteMetaRawTree, SELECT_ALL_VALUE } from "@/utils";
const list = generateRouteMetaRawTree(routes, {
  // 只要有menuShow就显示
  filterFn: (raw) => raw.menuShow,
  sortFn: (a, b) => a.menuSort - b.menuSort,
});
defineOptions({
  name: "SelectModule",
  inheritAttrs: true,
});
</script>
